package com.tian.cloud.web;

import com.tian.cloud.po.UserPO;
import com.tian.cloud.repository.UserRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserRepository userRepository;

    @PostMapping("/add")
    public UserPO add(@ModelAttribute UserPO user){
        return userRepository.save(user);
    }

    @GetMapping("/getUser/{id}")
    public UserPO getById(@PathVariable("id") Long id){
        return userRepository.findOne(id);
    }
}
